package com.woniu.user.controller;

import com.woniu.entity.Result;
import com.woniu.user.pojo.UserComments;
import com.woniu.user.service.IUserCommentsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lydia
 * @since 2023-02-22
 */
@RestController
@RequestMapping("/userComments")
@Api(tags = "用户评论管理")
public class UserCommentsController {

    @Autowired
    private IUserCommentsService userCommentsService;

    @ApiOperation("用户添加评论")
    @PostMapping("/{orderNo}/{username}/{content}")
    public Result addComment(@PathVariable String orderNo, @PathVariable String username, @PathVariable String content){
        //解析token
//        String token = request.getHeader("Authorization");
//        Claims claims = JwtUtil.parseJWT(token);
//        String username = (String) claims.get("username");

        int row = userCommentsService.addComment(orderNo, username,content);
        return Result.ok(20000,"添加评论成功",row);
    }

}
